Skip to content

feat(kernel): support federated token providers - #444

Merged
vuanhphung merged 8 commits into
mainfrom
vu-phung/kernel-federation-client-id
Aug 21, 2026
Merged

feat(kernel): support federated token providers#444
vuanhphung merged 8 commits into
mainfrom
vu-phung/kernel-federation-client-id

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Reuses WithFederatedTokenProvider* on the kernel backend. The driver snapshots one base-provider token for kernel-side PAT federation; WithFederatedTokenProviderAndClientID also forwards the SP-wide client ID. Because the kernel cannot refresh the provider, an expired token requires a new connection.

Pins KERNEL_REV to the federation-capable kernel. The kernel bump also requires aligning one retry-setter assertion with its clamp behavior.

Validation: go test ./..., make test-kernel, and make lint.

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@eric-wang-1990

Copy link
Copy Markdown
Contributor

For Go, we should also reuse-existing FederationProvider to avoid confusion as much as possible. Can we thread that through?
One path is we just get the token from the provider in the driver, then pass it to kernel as PAT with federation. That will fail in the case the token expired.

Long term is support custom token provider in kernel which is out of scope for now

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@vuanhphung vuanhphung changed the title feat(kernel): forward identity federation client ID feat(kernel): support federated token providers Aug 20, 2026

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 2 Low

Looks good — the federated-provider kernel wiring is correct: the wrapper preserves the Thrift path, GetToken is snapshotted exactly once (telemetry short-circuit verified by test), and the federation client ID is correctly gated to the PAT branch. Two minor low-severity items: one stale retry-range comment the kernel bump left behind, and missing coverage for the two new federated error paths.

Comment thread kernel_config.go
Comment thread kernel_config.go

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — the kernel federated-token path is implemented correctly: the base provider is snapshotted once (kernel does its own exchange via set_identity_federation_client_id), the telemetry classifier short-circuits to avoid a second GetToken, and the new federatedTokenAuthenticator wrapper is safe on the Thrift path (nothing type-asserts the concrete provider, and the embedded authenticator implements neither M2M/U2M interface). One low doc-consistency gap: CONNECTION_PARAMETERS.md's kernel notes weren't updated with the snapshot/expiry caveat that README got.

Comment thread CONNECTION_PARAMETERS.md

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — clean reuse of WithFederatedTokenProvider* on the kernel path with correct type-switch ordering, context-threaded token resolution, and a telemetry short-circuit that avoids a second provider snapshot. One low-severity question about the account-wide (no client-id) federation path.

Comment thread kernel_config.go
@vuanhphung

Copy link
Copy Markdown
Collaborator Author

@eric-wang-1990 PTAL!

@vuanhphung
vuanhphung force-pushed the vu-phung/kernel-federation-client-id branch from 0d6a9eb to 0dbbf2b Compare August 21, 2026 05:10

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — clean reuse of the federation authenticator that leaves the Thrift path byte-identical (embedded delegate) while snapshotting one token for the kernel, with correct type-switch ordering and no double GetToken (telemetry short-circuits). One low note: the kernel snapshots the base provider rather than the FederationProvider, so the account-wide (no-client-id) case relies on the kernel doing its own exchange — worth confirming that path is e2e-tested.

Comment thread kernel_config.go

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

Comment thread connector.go
// Wrap with federation provider that auto-detects need for token exchange
federationProvider := tokenprovider.NewFederationProvider(baseProvider, c.Host)
c.Authenticator = tokenprovider.NewAuthenticator(federationProvider)
c.Authenticator = &federatedTokenAuthenticator{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change affect existing Go Thrift side token-exchange feature?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eric-wang-1990 nope, this is just adding more metadata info. You can think of it like this

Before:

c.Authenticator = oldAuthenticator

After:

c.Authenticator = wrapper{
      Authenticator: oldAuthenticator,
      // kernel-only metadata
 }

calling c.Authenticator.Authenticate() still delegate to oldAuthenticator

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — clean, well-tested addition of federated-token support on the kernel backend. The base provider is snapshotted exactly once (telemetry short-circuits federatedTokenAuthenticator to avoid a second GetToken), context is properly threaded through validateKernelConfigContext/resolveKernelAuthContext, the Thrift exchange path is preserved and covered by a new httptest, and docs/CHANGELOG are updated consistently. One low-severity design question about the account-wide path is noted inline.

Comment thread kernel_config.go
if token == nil || token.AccessToken == "" {
return kernel.Auth{}, errors.New("databricks: the federated token provider returned an empty token")
}
return kernel.Auth{Mode: kernel.AuthPAT, Token: token.AccessToken, ClientID: a.clientID}, nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low — For the account-wide case (WithFederatedTokenProvider, no client ID), a.clientID is empty, so setAuth skips kernel_session_config_set_identity_federation_client_id and hands the raw external-IdP subject token to the kernel via set_auth_pat with no federation signal at all. The exchange the Thrift path performs in-driver (FederationProvider.GetToken) is not done here — it's delegated to the kernel, which for the SP-wide case is cued by the federation client ID but for account-wide has only the bare token to auto-detect from. Worth confirming that make test-kernel actually exercised the account-wide federated path (not just skipped it credential-gated) so the kernel is verified to auto-detect federation from the token alone; otherwise a raw external token could be sent straight through as a bearer PAT and rejected. If the kernel's account-wide auto-detection is a known guarantee, this is fine as-is.

(Anchored to the nearest changed line — see the description for the exact location.)

@vuanhphung
vuanhphung enabled auto-merge August 21, 2026 22:40
@vuanhphung
vuanhphung added this pull request to the merge queue Aug 21, 2026
Merged via the queue into main with commit 54bfa6c Aug 21, 2026
13 of 15 checks passed
@vuanhphung
vuanhphung deleted the vu-phung/kernel-federation-client-id branch August 21, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants